Option Explicit
dim swiftGrid:swiftGrid = 2

Dim doc
Set doc = application.ActiveDocument
main

' Function to validate document
Private Function ValidateServer(docObj)
    Dim key, licenseServer, licenseToken
    key = docObj.Validate(0)
    Set licenseServer = CreateObject("MGCPCBAutomationLicensing.Application")
    licenseToken = licenseServer.GetToken(key)
    Set licenseServer = nothing
    'On Error Resume Next
    Err.Clear
    docObj.Validate(licenseToken)
    If Err Then
        ValidateServer = 0    
    Else 
        ValidateServer = 1
    End If
End Function

sub GetUserLicence(docObj)

	If ValidateServer(docObj) = 0 Then
	    msgbox "Server validation failed."
	    exit sub
	End If
	
end sub

'----------------------------------------------------------------

sub UserEditCotrol(docObj)
	on error resume next
	docobj.currentunit = 2	
    Dim CustomGrid:CustomGrid=0   
    docObj.EditorControl.Grid (0,0)=CustomGrid
    docObj.EditorControl.Grid (1,0)=CustomGrid
    docObj.EditorControl.Grid (2,0)=CustomGrid
    docObj.EditorControl.Grid (3,0)=CustomGrid
    docObj.EditorControl.Grid (4,0)=CustomGrid
    docObj.EditorControl.Grid (5,0)=CustomGrid
    docObj.EditorControl.Grid (6,0)=CustomGrid
end sub

'----------------------------------------------------------------
sub main()
	GetUserLicence(doc)
	UserEditCotrol(doc)
end sub
'====================================================

































